package com.deco.dao.warpper.store;

import java.util.ArrayList;
import java.util.List;

import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Repository;

import com.deco.dao.delegate.store.IStoreShopDao;
import com.deco.dao.domain.table.StoreJoin;
import com.deco.dao.domain.table.StoreShop;
import com.deco.dao.logic.store.StoreShopDao;
import com.deco.domain.vo.store.StoreShopVo;
import com.free.common.vo.PageResponseVo;
import com.free.ext.mybatis.model.entity.PageResponseModel;
import com.free.ext.mybatis.warpper.BaseDaoWarpper;

/**
 * <p>
 * 功能概述:
 * </p>
 * <p>
 * 功能详述:
 * </p>
 */
@Repository
public class StoreShopDaoWarpper extends BaseDaoWarpper<StoreShopVo,Integer,StoreShop> implements IStoreShopDao {

    /*========================================================================*
     *                         Public Fields (公共属性)
     *========================================================================*/

    /*========================================================================*
     *                         Private Fields (私有属性)
     *========================================================================*/
    @Autowired
    private StoreShopDao storeShopDao;

    /*========================================================================*
     *                         Construct Methods (构造方法)
     *========================================================================*/

    /*========================================================================*
     *                         Public Methods (公有方法)
     *========================================================================*/

    @Override
    public void registerEnums() {

    }

	@Override
	public PageResponseVo<StoreShopVo> selectByPageNoNameLike(
			StoreShopVo conditionVo, String orderBy, Integer pageNo,
			Integer pageSize) {
		StoreShop tbl = convertToTable(conditionVo);
        PageResponseModel<StoreShop> pgModel = storeShopDao.selectByPageNoNameLike(tbl, orderBy, pageNo, pageSize);
        return convertToViewResponseVo(pgModel);
	}

	@Override
	public int batchDelete(Integer[] ids) {
		return storeShopDao.batchDelete(ids);
	}

	@Override
	public List<StoreShopVo> queryProvList(Integer type) {
		// TODO Auto-generated method stub
		List<StoreShop> shopList = storeShopDao.queryProvList(type);
		List<StoreShopVo> res = new ArrayList<StoreShopVo>();
		if(shopList != null && shopList.size() > 0){
			shopList.forEach(x -> {
				res.add(convertToView(x));
			});
		}
		return res;
	}

	@Override
	public List<StoreShopVo> queryCityList(Integer type, String prov) {
		List<StoreShop> shopList = storeShopDao.queryCityList(type, prov);
		List<StoreShopVo> res = new ArrayList<StoreShopVo>();
		if(shopList != null && shopList.size() > 0){
			shopList.forEach(x -> {
				res.add(convertToView(x));
			});
		}
		return res;
	}

	@Override
	public List<StoreShopVo> queryAreaList(Integer type, String city) {
		List<StoreShop> shopList = storeShopDao.queryAreaList(type, city);
		List<StoreShopVo> res = new ArrayList<StoreShopVo>();
		if(shopList != null && shopList.size() > 0){
			shopList.forEach(x -> {
				res.add(convertToView(x));
			});
		}
		return res;
	}


	@Override
	public List<StoreShopVo> selectByNameLike(StoreShopVo shop, String orderBy) {
		StoreShop tbl = convertToTable(shop);
		List<StoreShop> shopList =  storeShopDao.selectByNameLike(tbl, orderBy);
		 List<StoreShopVo> res = new ArrayList<StoreShopVo>();
		if(shopList != null && shopList.size() > 0){
			shopList.forEach(x -> {
		            res.add(convertToView(x));
		        });
		}
        return res;
	}


    /*========================================================================*
     *                         Private Methods (私有方法)
     *========================================================================*/
}
